package es.ojugames.yincana;

import android.app.Activity;
import android.content.Intent;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;

public class CheckLocationServiceActivity extends Activity {
	
	private LocationManager locManager;
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        
        locManager = (LocationManager)getSystemService(LOCATION_SERVICE);
        
        setContentView(R.layout.check_location_layout);
    }
	
	@Override
	public void onResume(){
		super.onResume();
		
		compruebaGPS();
	}
	
	private void compruebaGPS()
	{
		LinearLayout ventanaGPS = (LinearLayout) this.findViewById(R.id.ventanaGPS);
		
		if(!locManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
		{
        	ventanaGPS.setVisibility(View.VISIBLE);
		}
		else
		{
			ventanaGPS.setVisibility(View.GONE);
	    	finish();
		}
	}

	public void irAjustes(View v){
		Intent intent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
		startActivity(intent);
	}
}
